package com.servlet;


import com.entity.Flight;
import com.entity.OrderTicket;
import com.entity.UserInfo;
import com.service.cairns;
import org.apache.shiro.crypto.hash.Md5Hash;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class login {

    private cairns cairns;
       @Autowired
    public void setCairns(cairns cairns) {
        this.cairns = cairns;
    }

    @RequestMapping("zhuce")
      public  String  zhuce(UserInfo userInfo){
       String password =  userInfo.getLoginPassword();
       String  username=  userInfo.getLoginName();
       Md5Hash hash3 = new Md5Hash(password, username, 2);
       username=hash3.toString();
       userInfo.setLoginPassword(username);
        cairns.zhuce(userInfo);
        return  "seccess";
    }

    @RequestMapping("booking")
    public  String  booking(OrderTicket orderTicket){
        cairns.booking(orderTicket);
        return "user";
    }


    @RequestMapping("refund")
    public  String   refund(Integer flights){
        cairns.refund(flights);
           return "user";
    }

    @RequestMapping("/addzenjia")
    public  String  addzenjia(Flight flight){
       cairns.addzenjia(flight);
        return   "admin";
    }

    @RequestMapping("/updateFlight")
    public  String  updateFlight(Flight flight){
       cairns.updateFlight(flight);
        return   "admin";
    }


    @RequestMapping("deleteFlight")
    public  String   deleteFlight(Integer flights){
        cairns.deleteFlight(flights);
        return   "user";
    }


    @RequestMapping("updateadmin")
    public  String  updateadmin(UserInfo userInfo){
      String aa = userInfo.getLoginPassword();
      String  bb =userInfo.getUserName();
          cairns.updater(userInfo);
          return "user";
    }















}
